import 'package:flutter/material.dart';

import '../values/my_color.dart';

Widget commonConfirmDialog({
  required title,
  required context,
  required Function() onCancel,
  required Function() onConfirm,
  bool isShowCancel = true,
}) {
  return SimpleDialog(
    title: Container(
        alignment: Alignment.center,
        padding: EdgeInsets.symmetric(vertical: 10),
        child: Text(
          title,
          style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
        )),
    contentPadding: EdgeInsets.symmetric(horizontal: 15),
    titlePadding: EdgeInsets.zero,
    children: [
      Container(
        padding: const EdgeInsets.symmetric(vertical: 15),
        child: Text(
          context,
          textAlign: TextAlign.center,
          style: TextStyle(fontSize: 14, color: MyColor.c_99000000),
        ),
      ),
      Row(
        mainAxisAlignment: MainAxisAlignment.end,
        children: [
          isShowCancel
              ? InkWell(
                  onTap: () {
                    onCancel();
                  },
                  child: Container(
                      alignment: Alignment.center,
                      decoration: BoxDecoration(
                          color: MyColor.c_66000000,
                          borderRadius: BorderRadius.all(Radius.circular(5))),
                      padding: const EdgeInsets.symmetric(
                          vertical: 5, horizontal: 10),
                      child: Text("取消",
                          style: TextStyle(fontSize: 14, color: Colors.white))),
                )
              : SizedBox(),
          SizedBox(
            width: 20,
          ),
          InkWell(
            onTap: () {
              onConfirm();
            },
            child: Container(
                alignment: Alignment.center,
                decoration: BoxDecoration(
                    color: MyColor.account_color,
                    borderRadius: BorderRadius.all(Radius.circular(5))),
                padding:
                    const EdgeInsets.symmetric(vertical: 5, horizontal: 10),
                child: Text(
                  "确定",
                  style: TextStyle(fontSize: 14, color: MyColor.c_FFFFFFFF),
                )),
          )
        ],
      ),
      SizedBox(
        height: 20,
      )
    ],
  );
}
